package com.sjgtw.cloud.system.api.fallbackfactory;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import com.sjgtw.cloud.common.core.domain.R;
import com.sjgtw.cloud.system.api.domain.SysRole;
import com.sjgtw.cloud.system.api.service.RemoteRoleService;
import feign.hystrix.FallbackFactory;

/**
 * <p>Title: 角色服务异常处理</p>
 * <p>Description: </p>
 * @author Admin
 * @date 2021-8-13
 */
@Component
public class RemoteRoleFallbackFactory implements FallbackFactory<RemoteRoleService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteRoleFallbackFactory.class);

    @Override
    public RemoteRoleService create(Throwable throwable)
    {
        log.error("角色服务调用失败:{}", throwable.getMessage());
        return new RemoteRoleService()
        {
			@Override
			public R<SysRole> findRoleByRoleKey(String roleKey) {
				return R.fail("角色查询失败"+throwable.getMessage());
			}
        };
    }
}